#include "gmp++/gmp++.h"
#include "givtimer.h"
#include <iostream>
#include <cstdlib>

#define NB_REPETS 2000
#define MX 1000

int main(int argc, char ** argv)
{
	size_t nb_repets = NB_REPETS ;
	size_t mx        = MX ;
	if (argc==3) 
	{
		nb_repets = atoi(argv[1]) ;
		mx        = atoi(argv[2]) ;
	}

	Timer tim ; tim.clear() ; tim.start() ;
	Integer a = Integer::random(mx) ;
	Integer b = Integer::random(mx) ;
	Integer c = Integer::random(mx) ;
	Integer d ; 

	//
	for (size_t r = 0 ; r < nb_repets ; ++r) 
			Integer::axpy(d,a,b,c);
	tim.stop() ;
	std::cout << "axpy   : "<< tim << std::endl;

	//
	tim.clear() ; tim.start() ;
	for (size_t r = 0 ; r < nb_repets ; ++r) 
			d = a*b+c;
	tim.stop() ;
	std::cout << "=*+    : "<< tim << std::endl;

	//
	tim.clear() ; tim.start() ;
	for (size_t r = 0 ; r < nb_repets ; ++r) 
			Integer::axpyin(a,b,c);
	tim.stop() ;
	std::cout << "axpyin : "<< tim << std::endl;

	//
	tim.clear() ; tim.start() ;
	for (size_t r = 0 ; r < nb_repets ; ++r) 
			a += b*c ;
	tim.stop() ;
	std::cout << "+=*    : "<< tim << std::endl;

	//
	tim.clear() ; tim.start() ;
	for (size_t r = 0 ; r < nb_repets ; ++r) 
			Integer::add(a,b,c);
	tim.stop() ;
	std::cout << "add    : "<< tim << std::endl;

	//
	tim.clear() ; tim.start() ;
	for (size_t r = 0 ; r < nb_repets ; ++r) 
			a = b+c;
	tim.stop() ;
	std::cout << "=+     : "<< tim << std::endl;

	//
	tim.clear() ; tim.start() ;
	for (size_t r = 0 ; r < nb_repets ; ++r) 
			++a ;
	tim.stop() ;
	std::cout << "++x    : "<< tim << std::endl;

	//
	tim.clear() ; tim.start() ;
	for (size_t r = 0 ; r < nb_repets ; ++r) 
			a++ ;
	tim.stop() ;
	std::cout << "x++    : "<< tim << std::endl;


	//
	d = 1 ;
	tim.clear() ; tim.start() ;
	for (size_t r = 0 ; r < nb_repets ; ++r) 
			Integer::addin(a,1UL) ;
	tim.stop() ;
	std::cout << "++     : "<< tim << std::endl;


	return 0 ;
}


#undef NB_REPETS
#undef MX
